package com.hexacta.hrs.domain.mentoring;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.vectrics.common.db.AbstractRecordObject;

/**
 * Class that represents an action
 * 
 * @author vschimpf
 */
public class Action extends AbstractRecordObject {

    private String name;

    public String getName() {
        return name;
    }

    public String getEscapedName() {
        return StringEscapeUtils.escapeHtml(name);
    }

    public void setName(final String name) {
        this.name = name;
    }

    /**
     * Este m�todo crea una nueva instancia y copia todas las propiedades
     */
    public Action copy() {
        Action copyAction = new Action();
        copyAction.setName(getName());
        copyAction.setId(getId());
        return copyAction;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o)
            return true;
        if (o == null)
            return false;
        if (!(o instanceof Action))
            return false;
        final Action other = (Action) o;

        EqualsBuilder eb = new EqualsBuilder();
        eb.append(getName(), other.getName());
        if (getId() != null) {
            eb.append(getId(), other.getId());
        }

        return eb.isEquals();
    }

    @Override
    public int hashCode() {
        HashCodeBuilder hcb = new HashCodeBuilder();
        hcb.append(getName());
        if (getId() != null) {
            hcb.append(getId());
        }

        return hcb.toHashCode();
    }

}